trialInd=2

[newSM, ...
                updateSM, ...
                stim, ...                %trialRecords(trialInd).stim, ...
                LUT, ...
                trialRecords(trialInd).scaleFactor, ...
                trialRecords(trialInd).type, ...
                trialRecords(trialInd).targetPorts, ...
                trialRecords(trialInd).distractorPorts, ...
                stimulusDetails, ...
                trialRecords(trialInd).interTrialLuminance]= ...
                calcStim(stim2, ...
                class(nafc1), ...
                100, ...
                [1], ...
                getNumPorts(station), ...
                1280, ...
                1024, ...
                []);

            imagesc(reshape(stim(:,:,1),1024,1280));
            
            saveas(gcf, 'output', 'jpg')